#!/usr/bin/env python

import wx
import app
import view
import resource.string.app as rApp
import resource.dimen as rDimen
import resource.image as rImage

class About(wx.Dialog):
    '''About class
    
    @author Julot <andy.julot@gmail.com>
    @since Thursday, February 02, 2012. 11:17 PM'''
    
    def __init__(self, parent):
        wx.Dialog.__init__(self, parent)
        
        self.Title = 'About %s' % rApp.name
        self.SetTransparent(240)
        
        spacer = rDimen.spacer
        
        image = rImage.About.Image
        bitmap = wx.StaticBitmap(self, size=(image.Width, image.Height))
        bitmap.SetBitmap(image.ConvertToBitmap())
        
        panel = wx.Panel(self)
        panel.SetBackgroundColour(wx.Colour(255, 255, 255))
        
        label = '%s - %s' % (rApp.name, rApp.description)
        title = wx.StaticText(panel, label=label)
        font = title.GetFont()
        font.SetWeight(wx.FONTWEIGHT_BOLD)
        title.SetFont(font)

        label = 'Version %s' % rApp.humanVersion
        version = wx.StaticText(panel, label=label)
        
        s = rApp.releaseDate.strftime("%A, %B %d, %Y")
        label = 'Released at %s' % s
        release = wx.StaticText(panel, label=label)

        label = 'Created by %s <%s>' % (rApp.author, rApp.authorEmail)
        author = wx.StaticText(panel, label=label)

        label = 'Toolbar image by Fugue Icons <p.yusukekamiyamane.com>'
        credit = wx.StaticText(panel, label=label)
        
        label = rApp.longDescription
        about = wx.StaticText(panel, label=label)
        
        comment = wx.StaticText(panel, label=rApp.blessing)

        sizer4 = wx.BoxSizer(wx.VERTICAL)
        sizer4.AddSpacer(spacer)
        sizer4.Add(title)
        sizer4.Add(version)
        sizer4.Add(release)
        sizer4.AddSpacer(spacer)
        sizer4.Add(author)
        sizer4.Add(credit)
        sizer4.AddSpacer(spacer * 2)
        sizer4.Add(about)
        sizer4.AddStretchSpacer(1)
        sizer4.Add(comment)
        sizer4.AddSpacer(spacer)
        
        sizer3 = wx.BoxSizer(wx.HORIZONTAL)
        sizer3.AddSpacer(spacer)
        sizer3.Add(sizer4, 1, flag=wx.GROW)
        sizer3.AddSpacer(spacer * 2)
        panel.SetSizerAndFit(sizer3)
        
        sizer2 = wx.BoxSizer(wx.HORIZONTAL)
        sizer2.Add(bitmap, 0)
        sizer2.Add(panel, 1, flag=wx.GROW)
        
        image = rImage.Python.Image
        python = wx.StaticBitmap(self, size=(image.Width, image.Height))
        python.SetBitmap(image.ConvertToBitmap())

        image = rImage.Wx.Image
        wxPython = wx.StaticBitmap(self, size=(image.Width, image.Height))
        wxPython.SetBitmap(image.ConvertToBitmap())
        
        image = rImage.Sqlite.Image
        sqlite = wx.StaticBitmap(self, size=(image.Width, image.Height))
        sqlite.SetBitmap(image.ConvertToBitmap())
        
        button = self.CreateButtonSizer(wx.OK)
        
        footerSizer = wx.BoxSizer(wx.HORIZONTAL)
        footerSizer.AddSpacer(spacer)
        footerSizer.Add(python, 0)
        footerSizer.AddSpacer(spacer)
        footerSizer.Add(wxPython, 0)
        footerSizer.AddSpacer(spacer)
        footerSizer.Add(sqlite, 0)
        footerSizer.Add(button, 1, wx.ALIGN_BOTTOM | wx.ALIGN_RIGHT)
        footerSizer.AddSpacer(spacer)
        
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(sizer2, 0)
        sizer.AddSpacer(spacer)
        sizer.Add(footerSizer, 0, wx.GROW)
        sizer.AddSpacer(spacer)
        
        self.SetSizerAndFit(sizer)
